#include<bits/stdc++.h>
using namespace std;
map<string , int>mp;
string s;
char c;
int cnt;
int main(){
	freopen("speech.in" , "r" , stdin);
	freopen("speech.out" , "w" , stdout);
	while(c = getchar() , c != '\n'){
		if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')){
			s += c;
		}
		else if(c >= 'A' && c <= 'Z'){
			s = s + char(c + 32);
		}
		else{
			if(!s.empty()){
				if(mp.find(s) != mp.end()){
					mp[s]++;
				}
				else{
					mp[s] = 1;
				}
				s.clear();
			}
		}
	}
	for(auto it = mp.begin() ; it != mp.end() ; it++){
		if((*it).second > cnt){
			s = (*it).first;
			cnt = (*it) .second;
		}
	}
	cout << s << " " << cnt << endl;
	return 0;
}
